<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    function twoNumSum(arr,num){
        let arr2 = arr.sort((a,b)=>{
            return a-b
        })
        let left = 0
        let right = arr2.length-1
        while (left<right){
            if(arr2[left]+arr2[right]>num){
                right--
            }else if(arr2[left]+arr2[right]<num){
                left++
            }else{
                return [left,right]
            }
        }
        return null
    }
    twoNumSum([-4,-2,6,8,9,10,4],0)
</script>
</body>
</html>
